@isTest(SeeAllData=true)
private class AttachmentTest {
    static testMethod void testMethod1() {
        Contract__c c = new Contract__c();
        c.Corpcode__c = 'MKSY';
        c.Vsalestrucode__c = '05';
        c.Status__c='已生效';
        insert c;
        Attachment attch=new  Attachment();
        attch.Name='测试附件名称';
        attch.parentid=c.id;
        attch.Body=Blob.valueOf('aaaaaabbbbb');
        
        try{
            insert attch;
        }catch(Exception e){
            System.debug(e.getMessage());
        }


    }
    
    static testMethod void testMethod2() {
        Account acc = TestUtils.createAccount();
        acc.name = '附件测试客户';
        acc.Level__c = '一级医院';
        insert acc;
       NCCustomer__c cus = new NCCustomer__c();
       cus.Customer__c = acc.Id;
       insert cus;
       Attachment attch1=new  Attachment();
        attch1.Name='测试附件名称';
        attch1.parentid=cus.id;
        attch1.Body=Blob.valueOf('aaaaaabbbbb');
        insert attch1;

        
        ScheduledCargo__c sc = new ScheduledCargo__c();
        sc.Customer__c = acc.Id;

        insert sc ;

         Attachment attchsc=new  Attachment();
        attchsc.Name='测试附件名称';
        attchsc.parentid=sc.id;
        attchsc.Body=Blob.valueOf('aaaaaabbbbb');
        insert attchsc;
        



      
       Case c = new Case(
        	AccountId = acc.Id
        );
        insert c;
        
        WorkOrder__c wo = new WorkOrder__c(
        	Case__c = c.Id
        );
     wo.RecordTypeId = Utils.getRecordTypeIdByDevNameAndObjName('InstallationOrder','WorkOrder__c');
    
        wo.WhetherToMakeASingle__c = '是';
        insert wo;
     
        Attachment attch2 = new  Attachment();
        attch2.Name='安装附件名称';
        attch2.parentid=wo.id;
        attch2.Body=Blob.valueOf('aaaaaabbbbb');
        insert attch2;
        
          ProductStructure__c ps1 = new ProductStructure__c(
        	Classify1__c='生化'
        );
        insert ps1;

         Brand__c brand = new Brand__c(
            Name = '迈克生物',
            BrandShortName__c = '迈克生物'
            );
        insert brand;
     //创建安装产品
       Product__c  CL = new Product__c();
        CL.ProductStructure__c = ps1.Id;
       // ConfigurationList__c CL = new ConfigurationList__c();
        CL.RecordTypeId =  Utils.getRecordTypeIdByDevNameAndObjName('CompetitorProduct','Product__c');
        CL.Name='日立7020仪器安装所需';
         CL.CRMBrand__c = brand.Id;
         try {
             insert CL;
         }
         catch (Exception e) {
             
         }
         
        
          Dealer__c d = new Dealer__c(
        Name = 'xxxxx',
        Only__c = '13455666'

        );
      insert d;

        InstallationApply__c IA = new InstallationApply__c();
        //IA.Name='安装申请测试1';
        IA.Instrument__c=CL.Id;
        IA.NEWDealer__c = d.Id;
        IA.Hospital__c = acc.Id;
        IA.InstallEstiDate__c = Date.newInstance(2018, 12, 1);
        IA.InstallsNumber__c = 1;
        try {
            insert IA;
        }
        catch (Exception e) {
            
        }
        
            
         Attachment attch3=new  Attachment();
        attch3.Name='测试附件名称';
        attch3.parentid=IA.id;
        attch3.Body=Blob.valueOf('aaaaaabbbbb');
        try {
            insert attch3;
        }
        catch (Exception e) {
            
        }
        
        
        
        try{
            delete attch1;
            
           }catch(Exception e){
        
        }
		try{
            delete attch2;
            
           }catch(Exception e){
        
        }
        try{
            delete attch3;
            
           }catch(Exception e){
        
        } /*   */

    }
    
}